home *** CD-ROM | disk | FTP | other *** search
- /* file: subscr.dem */
- /* indices problem */
- /* This file demonstates the subscript mapping capability in MACSYMA which */
- /* useful for manipulating matrices, arrays, and arbitrary dimension and */
- /* order data objects constructed as lists of lists of lists... */
-
- SUBSCRMAP:TRUE /* This enables subscript mapping */;
- a[[x1,x2],[y1,y2]] /* Map a[x,x] over the subscripts */;
- m:matrix([a,b],[c,d]) /* enter a matrix */;
- M[[1,1,1],[[1,1],[2,2]]] /* Create a new structure from M */;
- af[i,j]:=x^(i+j) /* Define a generating function */;
- iota(n):= /* index list generator like APL */
- block([l], l:[],
- for i:1 thru n do l:endcons(i,l),
- l)$
- il:iota(8) /* generate an index vector 8 long */;
- af[il,il],eval /* Construct a structure */;
- apply(matrix,%) /* make it a matrix */;
- m[[2,1]],eval;
- apply(matrix,%);
- m[2] /* select a row */;
- matrix(m[[1,2],[1]]),eval /* select a column */;
- matrix(m[[2,1],''(iota(length(m[1])))]),eval /* select all of one dimension */;
- a['[1,2]] /* use a list as a hashed ary subscript*/;
- ARR[[1,2,3,4]]::0.0 /* Assignment. Note use of :: */;
-